﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using TFXK.Model;
using TFXK.BLL;
using TFXK.Common;
using log4net;

public partial class admin_CustomManage_Action : BasePage
{
    private static readonly ILog log = LogManager.GetLogger(typeof(admin_CustomManage_Action));
    private static readonly CustomsBLL bll = new CustomsBLL();

    #region 加载
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                InitAction();
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }

    }
    #endregion

    #region 绑定动作
    private void InitAction()
    {

        if (Request.QueryString["id"] != null)
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            InitData(id);
        }
        else
        {
            Response.Redirect("Default.aspx", false);
        }
    }
    #endregion

    #region 绑定
    private void InitData(int id)
    {
        Customs model = bll.GetModel(id);
        if (model != null)
        {
            hdfID.Value = id + "";
            lblCity.Text = model.userCity;
            lblEmail.Text = model.userEmail;
            lblPhone.Text = model.userPhone;
            lblTel.Text = model.userTel;
            lblTrueName.Text = model.trueName;
            lblLoginName.Text = model.loginName;
            ddlState.SelectedValue = model.userState + "";
           
        }
    }
    #endregion

    #region 添加/修改
    protected void ibtnAdd_Click(object sender, EventArgs e)
    {
        //验证代码
        try
        {
            Customs model = bll.GetModel(int.Parse(hdfID.Value));
            model.userState = int.Parse(ddlState.SelectedValue);
            bll.Update(model);
            Msg.ShowAndRedirect("修改信息成功!", "Default.aspx");

        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            Msg.Show("网络错误!原因:" + ex.Message);
        }
    }
    #endregion


    #region 返回
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }
    #endregion
}
